<script lang="tsx">
/**
 * 博客主题分类
 */
export default {
  name: "blogCategories"
}
</script>

<script lang="tsx" setup>
import {ref} from "vue"
import {definePageModel, PageModel} from "@/frame/view/layout/page-model/constructor.ts"

/**
 * 页面配置
 */
const pageModelRef = ref()
const config = definePageModel<any>({
  url: "/api/BlogCategories",
  searchForm: {
    els: [
      {
        eType: "el-input",
        prop: "name",
        props: {
          placeholder: "分类名称",
          clearable: true
        }
      }
    ]
  },
  programForm: {
    els: [
      {
        label: "新增",
        eType: "el-button",
        props: {
          type: "primary"
        },
        event: "add"
      }
    ]
  },
  table: {
    page: {
      enable: true,
      pageSize: 20
    },
    props: {
      stripe: true,
      border: true
    },
    operation: {
      width: 100,
      els: [
        {
          eType: "el-button",
          label: "编辑",
          event: "edit",
          props: {
            type: "primary",
            link: true
          },
          hide: false
        },
        {
          eType: "el-button",
          label: "删除",
          event: "delete",
          props: {
            type: "primary",
            link: true
          },
          hide: false
        }
      ]
    },
    els: [
      {
        label: "博客分类名称",
        prop: "name",
        minWidth: 60
      },
      {
        label: "排序",
        prop: "order",
        minWidth: 60
      }
    ]
  },
  form: {
    title: "新增/编辑",
    width: 500,
    sheetForm: {
      initValue: {
        isEnable: true
      },
      labelWidth: "100px",
      els: [
        {
          label: "博客分类名称",
          eType: "el-input",
          prop: "name",
          props: {
            placeholder: "博客分类名称",
            clearable: true
          }
        },
        {
          label: "排序",
          eType: "el-input",
          prop: "order",
          props: {
            placeholder: "排序",
            clearable: true
          }
        }
      ]
    }
  }
})

/**
 * 新增
 */
const handleAdd = () => {
  pageModelRef.value.handleAdd()
}

/**
 * 编辑
 */
const handleEdit = (row: any) => {
  pageModelRef.value.handleEdit(row)
}

/**
 * 删除
 */
const handleDelete = (row: any) => {
  pageModelRef.value.handleDelete(row)
}
</script>

<template>
  <PageModel ref="pageModelRef" :PageModel="config" @add="handleAdd" @delete="handleDelete" @edit="handleEdit"/>
</template>

<style lang="scss" scoped>
</style>